package JXY02.Day02;
/* 输入一个生产日期格式"yyyy-MM-dd",再输入一个数字(保质期的天数)。
 * 然后经过计算输出促销日期，促销日期为:该商品过期日前2周的周三
 *
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Text04 {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat format= new SimpleDateFormat("yyyy-MM-dd");
        String str = "2022-10-01";
        int t = 60;
        Date date = format.parse(str);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        calendar.add(Calendar.DATE,t);
        calendar.add(Calendar.WEEK_OF_YEAR,-2);
        calendar.set(Calendar.DAY_OF_WEEK,Calendar.WEDNESDAY);

        System.out.println(calendar.get(Calendar.YEAR)+" "+calendar.get(Calendar.MONTH)+" "+calendar.get(Calendar.DAY_OF_MONTH));
    }
}

